from playwright.sync_api import Page

class Dengluye:
    def __init__(self,page:Page):
        self.page = page

    def navigate(self):
        self.page.goto("http://asset.dasu123.inet/#/user/login")
        self.page.wait_for_timeout(5000)

    def fill_username(self,username):
        self.page.locator("input[type=\"text\"]").fill(username)
        self.page.wait_for_timeout(500)

    def fill_password(self,password):
        self.page.locator("input[type=\"password\"]").fill(password)
        self.page.wait_for_timeout(500)

    def click_loginbutton(self):
        self.page.get_by_role("button", name="登录").click()
        self.page.wait_for_timeout(1500)

    def click_logoutbutton(self):
        self.locator("header").get_by_role("img").nth(3).click()
        self.page.wait_for_timeout(500)
        self.page.get_by_role("menuitem", name="退出登录").click()
        self.page.wait_for_timeout(500)